#coding=utf-8

from random import randint

arr = [ randint(1,100) for i in range(11) ]
print("列表初始化:{}".format(arr))

def binary_query(sorted_arr, exp_val):
    '''二叉树查询
    '''
    left_idx = 0
    right_idx = len(sorted_arr)-1
    while left_idx <= right_idx:
        mid_idx = (left_idx + right_idx) //2
        if exp_val == sorted_arr[mid_idx]:
            return mid_idx
        elif exp_val < sorted_arr[mid_idx]:
            right_idx = mid_idx - 1
        elif exp_val > sorted_arr[mid_idx]:
            left_idx = mid_idx + 1
        else:
            pass
        
    return -1